#pragma once
#include <iostream>
#include <string>

std::string opers="+-*/%";

enum
{
    Success = 0,
    DivZero,
    ModZero,
    UnkownOper
};

class Task
{
public:
    Task(int data1, int data2, char oper)
        : data1_(data1), data2_(data2), oper_(oper)
    {
    }

    void operator()()
    {
        run();
    }

    std::string getResult()
    {
        std::string Result;
        Result = std::to_string(data1_) + 
        oper_ + std::to_string(data2_) + 
        "=" + std::to_string(result_)+"["+std::to_string(exitcode_)+"]";
        return Result;
    }

    std::string getTask()
    {
        std::string r = std::to_string(data1_);
        r+= oper_;
        r+= std::to_string(data2_);
        r+= "= ?";
        return r;
    }
private:
    void run()
    {
        switch (oper_)
        {
        case '+':
            result_ = data1_ + data2_;
            break;
        case '-':
            result_ = data1_ - data2_;
            break;
        case '*':
            result_ = data1_ * data2_;
            break;
        case '/':
            if (data2_ == 0)
            {
                exitcode_ = DivZero;
            }
            else
            {
                result_ = data1_ / data2_;
            }
            break;
        case '%':
            if (data2_ == 0)
            {
                exitcode_ = ModZero;
            }
            else
            {
                result_ = data1_ % data2_;
            }
            break;
        default:
            exitcode_ = UnkownOper;
            break;
        }
    }
    int data1_;
    int data2_;
    char oper_;

    int result_;
    int exitcode_ = 0;
};